<template>
	<!-- 添加车辆 -->
	<view class="addCar">
		<!-- <u-navbar title="添加车辆" title-color="#333" back-icon-color="#333"></u-navbar> -->
		<view class="addCar-bottom">
			<view class="tit-fp">
				<uni-title type="h1" align="center" :title="obj.SETTB410CA03"></uni-title>
			</view>

			<view class="addCar-content-box">

				<view class="addCar-carName-phone">
					<text class="addCar-phone">税号</text>

					<text class="fpmsg-xqxx">{{obj.SETTB410CA04.replace(/(\w{4})(?=\w)/g, "$1 ")||''}}</text>

				</view>
				<!-- <view class="add-phone" @click="addItem">添加</view> -->

				<view class="addCar-carName-phone">
					<text class="addCar-phone">单位地址</text>
					<text class="fpmsg-xqxx">{{obj.SETTB410CA16}}</text>
				</view>
				<view class="addCar-carName-phone">
					<text class="addCar-phone">电话</text>
					<text class="fpmsg-xqxx">{{obj.SETTB410CA02}}</text>
				</view>
				<view class="addCar-carName-phone">
					<text class="addCar-phone">开户银行</text>
					<text class="fpmsg-xqxx">{{obj.SETTB410CA15}}</text>
				</view>
				<view class="addCar-carName-phone">
					<text class="addCar-phone">银行账户</text>
					<text class="fpmsg-xqxx">{{obj.SETTB410CA05}}</text>
				</view>
			</view>
			<!--  -->

			<view class="addCar-reset-determine">

				<view class="addCar-determine" @click="copyContent(obj)">复制全部资料</view>
			</view>

			<view class="addCar-reset-determine dbdw-main">
				<!-- <view class="addCar-reset" style="background: rgba(234, 197, 15, 1);" @click="reset">修改</view> -->
				<view class="addCar-determine" style="background:red;" @click="determine">删除</view>
			</view>
		</view>
		<u-modal v-model="addCarLoginShow" content="删除当前发票抬头信息？" cancel-text="暂不删除" confirm-text="删除" confirm-color="#FF0033" :show-cancel-button="true" @confirm="addCarConfirm">
		</u-modal>
		<u-keyboard ref="uKeyboard" mode="card" @change="carValChange" :autoChange="isChange" @backspace="carBackspace"
			v-model="carshow" :mask="false"></u-keyboard>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: JSON.parse(uni.getStorageSync('userinfo')),
				componeryArr: [],
				addressNew: null,
				Index: 0,
				diasabledInput: true, //可读不可写
				carNumberIpt: '', //车牌号
				nameIpt: '', //车主姓名
				phoneIpt: '', //联系方式
				tareIpt: '', //联系方式
				obj: {},
				addCarLoginShow: false,
				carshow: false,
				carType: '',
				isChange: false, //是否改变为英文
				list: [{
					phone: ''
				}]
			}
		},
		onLoad(ops) {
			console.log(ops)
			let objStr = decodeURIComponent(ops.item);
			let obj = JSON.parse(objStr); // 将字符串转换回对象
			console.log(obj.SETTB410CA03); // 输出对象
			this.obj = obj
		},
		onShow() {

		},
		methods: {
			copyContent() {
				const dz = '名称：' + this.obj.SETTB410CA03 + '\n' + '税号：' + this.obj.SETTB410CA04 + '\n' + '单位地址：' + this.obj.SETTB410CA16 + '\n' +
					'电话：' + this.obj.SETTB410CA02 + '\n' + '开户银行：' + this.obj.SETTB410CA15 + '\n' + '银行账户：' + this.obj.SETTB410CA05 + '\n'
				console.log(dz)
				uni.setClipboardData({
					data: dz + '', //	这里是个坑接受字符串类型 value转化为字符串
					success: function() {
						//调用方法成功
						console.log('success');
					}
				})
			},
			addItem() {
				if (this.list.length == 3) {
					uni.showToast({
						title: '最多三个',
						icon: 'none'
					})
					return false
				}
				// let add = {
				// 	id: parseInt(this.id) + 1
				// }
				this.list.push({
					phone: ''
				})
				// this.id = parseInt(this.id) + 1
				// this.phoneIpt += parseInt(this.id) + 1
				// console.log(this.list)
			},
			delItem(item) {
				if (this.list.length == 1) {
					uni.showToast({
						title: '不能删除第1个',
						icon: 'none'
					})
					return false;
				}
				this.list = this.list.filter((i) => {
					return i != item
				})
			},
			carValChange(val) {
				console.log(this.carNumberIpt.length)


				// 将每次按键的值拼接到carNumberIpt变量中，注意+=写法
				this.carNumberIpt += val;

				if (this.carNumberIpt.length == 0) {
					this.isChange = true;
				} else {
					this.isChange = false;
				}
			},
			carBackspace() {
				// 删除carNumberIpt的最后一个字符
				if (this.carNumberIpt.length) this.carNumberIpt = this.carNumberIpt.substr(0, this.carNumberIpt.length -
					1);
			},
			boardClick() {
				this.carshow = true
			},
			tareIptInput() { //限制验证码长度
				if (this.tareIpt.length > 6) {
					this.tareIpt = this.tareIpt.slice(0, 6)
				}
			},
			phoneIptInput() {
				if (this.phoneIpt.length > 11) {
					this.phoneIpt = this.phoneIpt.slice(0, 11)
				}
			},
			// 确定
			determine() {


				this.addCarLoginShow = true

			},
			addCarConfirm() {
				if (this.userinfo.sign == 'CUS-1') {
					var ORMTB400ID = this.userinfo.ORMTB400ID
				} else if (this.userinfo.sign == 'CUS-2' || this.userinfo.sign == 'CUS-3') {
					var ORMTB400ID = this.userinfo.ORMTB410ID
				}
				uni.request({
					url: this.baseUrl + '/set/settb416/settb461Delete',
					method: 'POST',
					dataType: 'json',
					data: {
						SETTB416ID: this.obj.SETTB416ID,
						SETTB410CA00: ORMTB400ID
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							uni.showToast({
								title: '删除成功',
								duration: 5000,
								icon: 'none',
							});
							uni.navigateBack()
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 5000,
								icon: 'none',
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
				});
			},
			// 重置
			reset() {
				this.carNumberIpt = '' //车牌号
				this.nameIpt = '' //车主姓名
				this.phoneIpt = '' //联系方式
				this.tareIpt = ''
			},
		}
	}
</script>

<style scoped>
	.addCar input {
		border: 0;
	}

	.addCar {
		width: 100%;
		min-height: 90vh;
		/* background-color: rgba(242, 242, 242, 1); */
		overflow: hidden;
	}

	/* 列表 */

	/* 内容 */
	.addCar-content-box {
		width: 100%;
		background: rgba(255, 255, 255, 1);
		padding: 0 24rpx;
	}

	.addCar-carName-phone {
		/* border-bottom: 2rpx solid rgba(230, 230, 230, 1); */
		padding: 30rpx 0;
		display: flex;
		line-height: 60rpx;
	}

	.addCar-input-one {
		width: 310rpx !important;
		display: inline-block;
		margin-bottom: 0 !important;
		padding: 0 !important;
		height: 44rpx !important;
		vertical-align: middle;
		/* margin-left: 0.1rem; */
		color: rgba(51, 51, 51, 1);
		/* font-size: 28rpx; */
		text-align: center;
	}

	.addCar-phone {
		width: 210rpx;
		display: inline-block;
		/* font-size: 30rpx; */
		color: rgba(102, 102, 102, 1);
		vertical-align: middle;
		/* background: #000000; */
	}

	.addCar-phone-placeholder {
		font-size: 30rpx;
		color: rgba(102, 102, 102, .5);
	}

	.addCar-dun {
		color: rgba(51, 51, 51, 1);
		font-size: 30rpx;
	}

	/* 按钮 */
	.addCar-reset-determine {
		margin-top: 167rpx;
		display: flex;
		/* justify-content: center; */
	}



	.addCar-reset-determine>view {
		width: 350rpx;
		text-align: center;
		line-height: 80rpx;
		background-color: #19be6b;
		color: #fff;
		font-size: 36rpx;
		margin: 0 auto;
		border-radius: 10rpx;
	}

	.addCar-reset {
		width: 159rpx;
		background: rgba(234, 197, 15, 1);
		text-align: center;
		/* margin-left: 170rpx; */
		margin: 0 20rpx;
	}

	.addCar-determine {
		background: rgba(0, 161, 244, 1);
		/* margin-left: 60rpx; */
	}

	.add-phone-main {
		position: relative;
	}

	.add-phone {
		position: absolute;
		top: 20rpx;
		right: 0;
		/* font-size: 50rpx; */
		color: rgba(0, 255, 127, 1);
		/* background: rgba(0, 255, 127, 1); */

	}

	.addCar-phone-car {
		display: inline-block;
		width: 310rpx;
		height: 44rpx;
		line-height: 44rpx;
		/* border: 1px solid rgba(0, 0, 0, .2); */
		/* border-radius: 3px; */
		text-align: center;
		vertical-align: middle;
		font-size: 30rpx;
	}

	input::placeholder {
		color: rgba(102, 102, 102, .5);
	}

	.item-box {
		display: flex;
	}

	.tit-fp {
		background-color: #fff;
		/* border-bottom: 2rpx solid rgba(230, 230, 230, 1); */
		padding-bottom: 30rpx;
	}

	.fpmsg-xqxx {
		width: 500rpx;
		display: inline-block;

		/* font-size: 30rpx; */
		/* color: rgba(102, 102, 102, 1); */
		vertical-align: middle;
		/* background: #000000; */
	}

	.dbdw-main {
		width: 100%;
		position: fixed;
		z-index: 999;
		bottom: 0;
		margin-top: 0;
		padding-bottom: 20rpx;
	}
</style>
